/**
 * Copyright (C) 2013 DaiKit.com - daikit-commons module (admin@daikit.com)
 *
 *         Project home : http://code.daikit.com/commons
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.daikit.commons.shared.bean;



/**
 * Base User that extending application User DTO should extend
 * 
 * @author tcaselli
 * @version $Revision$ Last modifier: $Author$ Last commit: $Date$
 */
public class BaseUser extends AbstractDkModifiableBeanWithId implements Comparable<BaseUser>
{

	private static final long serialVersionUID = -8783456356366703639L;
	protected transient String password;
	protected String email;
	protected String firstName;
	protected String lastName;

	// -------------------------------------------------------------------------------------------
	// ------------ METHODS
	// -------------------------------------------------------------------------------------------


	@Override
	protected StringBuilder getToStringBuilder()
	{
		final StringBuilder stringBuilder = super.getToStringBuilder();
		stringBuilder.append(",password=").append(getPassword());
		stringBuilder.append(",email=").append(getEmail());
		stringBuilder.append(",firstName=").append(getFirstName());
		stringBuilder.append(",lastName=").append(getLastName());
		return stringBuilder;
	}

	@Override
	public boolean equals(final Object other)
	{
		return other != null && other instanceof BaseUser && id != null && id.equals(((BaseUser) other).getId());
	}

	@Override
	public int compareTo(final BaseUser o)
	{
		return o == null ? -1 : -(o.getLastName() + o.getFirstName() + getEmail()).compareTo(getLastName() + getFirstName()
				+ getEmail());
	}

	@Override
	public String getAsSimpleString()
	{
		return getLastName() + " " + getFirstName();
	}

	// -------------------------------------------------------------------------------------------
	// ------------ GETTERS / SETTERS
	// -------------------------------------------------------------------------------------------

	/**
	 * @return the password
	 */
	public String getPassword()
	{
		return password;
	}

	/**
	 * @param password
	 *           the password to set
	 */
	public void setPassword(final String password)
	{
		this.password = password;
	}

	/**
	 * @return the email
	 */
	public String getEmail()
	{
		return email;
	}

	/**
	 * @param email
	 *           the email to set
	 */
	public void setEmail(final String email)
	{
		this.email = email;
	}

	/**
	 * @return the firstName
	 */
	public String getFirstName()
	{
		return firstName;
	}

	/**
	 * @param firstName
	 *           the firstName to set
	 */
	public void setFirstName(final String firstName)
	{
		this.firstName = firstName;
	}

	/**
	 * @return the lastName
	 */
	public String getLastName()
	{
		return lastName;
	}

	/**
	 * @param lastName
	 *           the lastName to set
	 */
	public void setLastName(final String lastName)
	{
		this.lastName = lastName;
	}
}
